package com.DeliveryProgram.www.constant;

import com.DeliveryProgram.www.po.Business;
import com.DeliveryProgram.www.po.Comment;
import com.DeliveryProgram.www.po.Menu;
import com.DeliveryProgram.www.po.Order;

import java.util.List;

/**商户系统内部功能的界面UI*/
public class BuScreen {

    /**展示商家的基本信息*/
    public static void showMessage(Business bu){
        System.out.println("---------------------------");
        System.out.println("|欢迎来到广东工业大学外卖系统商家版|");
        System.out.println("---------------------------");
        /**显示目前店铺的基本信息*/
        System.out.println(bu.getShopname());
        System.out.println(bu.getIndroduce());
        System.out.println("---------------------------");
        System.out.println("当前收益："+bu.getEarn());
        System.out.println("---------------------------");
        System.out.println("|1-修改店名 2-修改简介 3-离开  |");
        System.out.println("---------------------------");


    }

    /**展示商家的订单及完成情况*/
    public static void showOrders(Business bu) {
        System.out.println("————————————————————————————————————————————");
        List<Order> list = bu.getOrders();
        /**接受订单判断状态*/
        String str = null;
        try {
            for (int i = 0; i < list.size() && list.size() != 01; i++) {
                /**判断订单状态*/
                switch (list.get(i).getIsComplete()) {
                    case 1:
                        str = "未接单";
                        break;
                    case 2:
                        str = "已接单";
                        break;
                    case 3:
                        str = "已完成";
                        break;
                }
            }
        }catch (NullPointerException e){
            e.printStackTrace();
        }finally {
            System.out.println("请输入订单编号操作具体订单（输入0返回主界面）");
        }
    }

    /**展示某一份订单*/
    public static void showOrder(Business bu,int num){
        System.out.println("————————————————————————————————————————————");
        /**接受订单判断状态*/
        String str=null;
        /**判断订单状态*/
        switch (bu.getOrders().get(num).getIsComplete()){
            case 1:str="未接单";break;
            case 2:str="已接单";break;
            case 3:str="已完成";break;
        }
        System.out.println("日期："+bu.getOrders().get(num).getDate()+"|价格："+bu.getOrders().get(num).getMoney()+"|完成状态："+str);
        /**展示地址*//**   id;addr;phone;customer;*/
        System.out.println("用户："+bu.getOrders().get(num).getAddress().getCustomer()+"|手机号码："+bu.getOrders().get(num).getAddress().getPhone()+"|地址："+bu.getOrders().get(num).getAddress().getAddr());
        /**展示菜单*/
        for (int i = 0; i < bu.getOrders().get(num).getOdmu().size(); i++){
            System.out.println(bu.getOrders().get(num).getOdmu().get(i).getMount()+"份"+bu.getOrders().get(num).getOdmu().get(i).getName());
        }
        System.out.println("————————————————————————————————————————————");
        System.out.println("1-修改订单状态 0-退出");
    }

    /**展示该商家的所有评论*/
    public static void showComment(Business bu) {
        try {
            List<Comment> list = bu.getComments();
            for (int i = 0; i < list.size() && list.size() != 0; i++) {
                System.out.println(bu.getComments().get(i).getWriter() + ":" + bu.getComments().get(i).getComm() + "[" + bu.getComments().get(i).getDate() + "]");
            }
        }catch (NullPointerException e){
            e.printStackTrace();
            return;
        }finally {
            if(bu.getName()!=null) {
                System.out.println("————————————————————————————————————————————");
                System.out.println("0-返回 1-添加评论");
            }
        }
    }

    /**展示商家菜单界面*/
    public static void showMenu(Business bu){
        try {
            for (int i = 0; i < bu.getMenu().size() && bu.getMenu().size() != 0; i++) {
                /**将0空出来作为退出键*/
                System.out.println((i + 1) + "、" + bu.getMenu().get(i).getName() + " " + bu.getMenu().get(i).getIntroduce() + "  $" + bu.getMenu().get(i).getPrice());
            }
        }catch (NullPointerException e){
            e.printStackTrace();
        }
    }

    /**展示商家折扣界面*/
    public static void showCoupons(Business bu){
        try {
            for (int i = 0; i < bu.getCoupons().size() ; i++) {
                /**将0空出来作为退出键*/
                System.out.println((i + 1) + "、" + bu.getCoupons().get(i).getDiscount() + "折 | " + bu.getCoupons().get(i).getMount() + "张");
            }
        }catch (NullPointerException e){
            e.printStackTrace();
        }
    }

}
